<?php
/**
 * 系统设置
 * @author Kevin_ren  <330202207@qq.com>
 */

namespace Admin\Controller;

use Common\Controller\BaseManageController;

class SettingController extends BaseManageController
{

    public function site()
    {
        if (IS_POST) {
            $data = I('post.data', false);
            $data = serialize($data);
            D('Setting')->save(array('k' => 'site', 'v' => $data));
            D('Setting')->cleanCache();
            $this->simpleSuccess('设置成功', U('setting/site'));
        } else {
            $this->display();
        }
    }

    public function attachs()
    {
        if (IS_POST) {
            $data = I('post.data', false);
            $data = serialize($data);
            D('Setting')->save(array('k' => 'attachs', 'v' => $data));
            D('Setting')->cleanCache();
            $this->simpleSuccess('设置成功', U('setting/attachs'));
        } else {
            $this->display();
        }
    }

    public function mail()
    {
        if (IS_POST) {
            $data = I('post.data', false);
            $data = serialize($data);
            D('Setting')->save(array('k' => 'mail', 'v' => $data));
            D('Setting')->cleanCache();
            $this->simpleSuccess('设置成功', U('setting/mail'));
        } else {
            $this->display();
        }
    }

    public function index()
    {
        if (IS_POST) {
            $data = I('post.data', false);
            $data = serialize($data);
            D('Setting')->save(array('k' => 'index', 'v' => $data));
            D('Setting')->cleanCache();
            $this->simpleSuccess('设置成功', U('setting/index'));
        } else {
            $this->assign('cates', D('Shopcate')->fetchAll());
            $this->display();
        }
    }

}
